<?php

namespace app\admin\model\tongcheng;

use addons\tongcheng\model\BaseModel;


class SystemConfigModel extends BaseModel
{


    // 表名
    protected $name = 'tongcheng_system_config';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];


    /**
     * 获取配置
     * @return SystemConfigModel
     */
    public static function getOne()
    {
        $config = self::find();
        if (!$config) {
            $config = self::create([
                'wx_mini_app_id'     => '',
                'wx_mini_app_secret' => '',
                'wx_pay_mch_id'      => '',
                'wx_pay_v2_key'      => '',
                'share_title'        => '',
                'share_image'        => '',
                'tx_map_key'         => '',
                'index_top_style'    => 'banner',
            ]);
        }
        return $config;
    }

    public static function getValue($key)
    {
        $config = self::getOne();
        return $config[$key] ?? '';
    }

    /**
     * 获取小程序主题列表
     * @return array[]
     */
    public static function getMiniAppThemeList()
    {
        return [
            [
                'name'  => 'red',
                'text'  => '红色',
                'color' => '#E83A30',
            ],
            [
                'name'  => 'purplered',
                'text'  => '紫红色',
                'color' => '#E72F8C',
            ],
            [
                'name'  => 'purple',
                'text'  => '紫色',
                'color' => '#892FE8',
            ],
            [
                'name'  => 'bluepurple',
                'text'  => '蓝紫色',
                'color' => '#5F4FD9',
            ],
            [
                'name'  => 'aquablue',
                'text'  => '海蓝色',
                'color' => '#3646FF',
            ],
            [
                'name'  => 'blue',
                'text'  => '蓝色',
                'color' => '#3D7EFF',
            ],
            [
                'name'  => 'indigo',
                'text'  => '靛蓝',
                'color' => '#31C9E8',
            ],
            [
                'name'  => 'green',
                'text'  => '绿色',
                'color' => '#31E749',
            ],
            [
                'name'  => 'yellowgreen',
                'text'  => '黄绿色',
                'color' => '#A4E82F',
            ],
            [
                'name'  => 'orangeyellow',
                'text'  => '橘黄色',
                'color' => '#FFCA28',
            ],
            [
                'name'  => 'orange',
                'text'  => '橙色',
                'color' => '#FFA726',
            ],
            [
                'name'  => 'orangered',
                'text'  => '橘红色',
                'color' => '#FF7043',
            ],
        ];
    }
}
